package com.whale;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.whale.api.IWebApiService;
import com.whale.api.impl.DefaultWebApiService;
import com.whale.entity.UserProfile;
import com.whale.util.image.ImageCanvas;
import com.whale.util.image.ImageDownloader;
import com.whale.util.image.ImageDownloaderWithCache;
import com.whale.widget.ProgressDialog;

/**
 * 类WhaleApplication.java的实现描述：全局共享的放这里
 * 
 * @author alibaba 2011-9-17 下午03:30:28
 */
public class WhaleApplication extends Application {

    /** 登录后用户信息 */
    public static UserProfile              userProfile;

    /** 在程序中都用此Context,以便后续实现换肤 */
    public static Context                  mContext;

    public static SharedPreferences        mPreferences;

    public static IWebApiService           webApiService;

    public static ProgressDialog           progressDialog;

    public static ImageCanvas              mImageCanvas;

    public static ImageDownloader          mImageDownLoader;

    public static ImageDownloaderWithCache mIDWithCache;

    public static boolean bNeedRefreshHome = true;
    
    @Override
    public void onCreate() {
        super.onCreate();

        mContext = this.getApplicationContext();

        mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

        // here just use mockService
        webApiService = new DefaultWebApiService();

        progressDialog = new ProgressDialog(mContext);

        mImageCanvas = new ImageCanvas(mContext);

        mImageDownLoader = new ImageDownloader();

        mIDWithCache = new ImageDownloaderWithCache(mContext);
    }

}
